﻿@model BcdVolumeDirectoryViewModel
@{
    Layout = null;
    ViewBag.Title = "未归档文件选择列表";
}
<div class="pageContent" layouth="45" id="div_fileCheckList">
    @using (Html.BeginForm("FileCheckListSplitPage", "VolumeList", null, FormMethod.Post, new { id = "pagerForm", name = "pagerForm_volume", onsubmit = "return dwzSearch(this, 'dialog');" }))
    {
        <input type="hidden" name="pageNum" value="1" />
        <input type="hidden" name="numPerPage" value="@(ViewBag.numPerPage)" />
        <input type="hidden" name="pftId" value="@(ViewBag.pftId)" />
        <input type="hidden" name="fileIds" value="@(ViewBag.fileIds)" />
        <ul class="searchBar">
            <li><span>文件编号：</span>
                <input type="text" name="iput_ch_code" value="@(ViewBag.iput_ch_code)" />
            </li>
            <li><span>文件材料题名：</span>
                <input type="text" name="iput_ch_name" value="@(ViewBag.iput_ch_name)" />
            </li>
            <li>
                <button type="submit" class="btn btn-success btn-xs">
                    搜索</button>
            </li>
        </ul>
   
    }
    <table class="table" width="100%" nowraptd="false" targettype="dialog" layouth="140">
        <thead>
            <tr align="center">
                <th width="20">
                    <input type="checkbox" group="ids" class="checkboxCtrl" title="全选">
                </th>
                <th width="30">序号</th>
                <th width="120">文件编号</th>
                <th>文件材料题名</th>
                <th width="40">总页数</th>
            </tr>
        </thead>
        <tbody>
            @{int numb = 0;}
            @foreach (var item in Model.TheBcdVolumedirectoryList)
            {
                numb++;
                string ch = "";
                string fids = ViewBag.fileIds;
                if (fids.IndexOf(item.Vd_ID) >= 0)
                {
                    ch = "checked='checked'";
                }
                <tr target="ids" rel="@item.Vd_ID" align="center">
                    <td>
                        <input name="ids" @(ch) id="input_@(item.Vd_ID)" value="@(item.Vd_ID)" data-id="@(item.Vd_ID)" data-order="@(item.Vd_Order)" data-code="@(item.Vd_Code)" data-name="@(item.Vd_Name)" data-pagenumb="@(item.Vd_PageNumb)" data-page="@(item.Vd_Page)"  type="checkbox">
                    </td>
                    <td>
                        @(numb)
                    </td>
                    <td>@(item.Vd_Code)</td>
                    <td>@(item.Vd_Name)</td>
                    <td>@(item.Vd_PageNumb)</td>
                </tr>
            }
        </tbody>
    </table>
    <div class="panelBar" style="border-bottom: none;">
        <div class="pages">
            <span>显示</span>
            <select class="comsplitpage" name="numPerPage" onchange="dialogPageBreak({ numPerPage: this.value })">
                <option value="10" @(ViewBag.numPerPage == 10 ? "selected='selected'" : "")>10</option>
                <option value="20" @(ViewBag.numPerPage == 20 ? "selected='selected'" : "")>20</option>
                <option value="50" @(ViewBag.numPerPage == 50 ? "selected='selected'" : "")>50</option>
            </select>
            <span>条，共@(ViewBag.pagenumshown)页,@(ViewBag.totalcount)条</span>
        </div>
        <div class="pagination" targettype="dialog" totalcount="@(ViewBag.totalcount)" numperpage="@(ViewBag.numPerPage)" pagenumshown="5" currentpage="@(ViewBag.pageNum)">
        </div>
    </div>
</div>
<div class="formBar">
    <ul>
        <li>
            <button type="button" class="btn btn-success btn-sm" onclick="fileCheck()">
                选择</button>
        </li>
        <li>
            <button type="button" class="close btn btn-default btn-sm">
                取消</button>
        </li>
    </ul>
</div>
<script>
    function fileCheck() {
        var index = 0;
        var tr_html = "";
        var fileIds = "";
        $("#div_fileCheckList input[name='ids']:checkbox:checked").each(function () {
            var id = $(this).data("id");
            var order = $(this).attr("data-order");
            var code = $(this).data("code");
            var name = $(this).data("name");
            var pagenumb = $(this).data("pagenumb");
            var page = $(this).data("page");
            if ($("#tr_" + id).length > 0) {
                order = $("#tr_" + id).find("input:eq(1)").val();
                code = $("#tr_" + id).find("input:eq(2)").val();
                name = $("#tr_" + id).find("input:eq(3)").val();
                page = $("#tr_" + id).find("input:eq(4)").val();
            }
            fileIds += id + ",";
            tr_html += "<tr id='tr_" + id + "'>"
                        + "<td><input id='TheBcdVolumedirectoryList_" + index + "__Vd_ID' name='TheBcdVolumedirectoryList[" + index + "].Vd_ID' type='hidden' value='" + id + "'/>"
                            + "<input id='TheBcdVolumedirectoryList_" + index + "__Vd_Order' name='TheBcdVolumedirectoryList[" + index + "].Vd_Order' size='5' type='text' value='" + order + "' class='textInput'/></td>"
                        + "<td><input id='TheBcdVolumedirectoryList_" + index + "__Vd_Code' name='TheBcdVolumedirectoryList[" + index + "].Vd_Code' size='15' type='text' value='" + code + "' class='textInput'/></td>"
                        + "<td><input data-val='true' data-val-required='*' id='TheBcdVolumedirectoryList_" + index + "__Vd_Name' name='TheBcdVolumedirectoryList[" + index + "].Vd_Name' size='50' type='text' value='" + name + "' class='textInput input-validation-error'/>"
                        + "<span class='field-validation-valid' data-valmsg-for='TheBcdVolumedirectoryList[" + index + "].Vd_Name' data-valmsg-replace='true'></span></td>"
                        + "<td>" + pagenumb + "</td>"
                        + "<td><input id='TheBcdVolumedirectoryList_" + index + "__Vd_Page' name='TheBcdVolumedirectoryList[" + index + "].Vd_Page' size='7' type='text' value='" + page + "' class='textInput'/></td>"
                        + '<td style="padding-left:10px;"><a title="删除" href="javascript:delFile(\'' + id + '\')" class="btnDel">删除</a></td>'
                      + "</tr>"
            index++;
        })
        $("#input_fileIds").val(fileIds);
        $("#table_fileList").html("<tr><td width='60'>卷内序号</td><td width='140'>文件编号</td><td>文件材料题名</td><td width='50'>总页数</td><td width='75'>卷内页数</td><td width='45'>操作</td></tr>");
        $("#table_fileList").append(tr_html);
        $("#table_fileList").initUI();
        $.pdialog.close("jgzl_wjxz_list");
    }
</script>
